/*
 * @Author: Qimu
 * @Date: 2020-04-22 15:55:22
 * @LastEditors: Qimu
 * @LastEditTime: 2020-05-16 23:30:20
 * @Description: file content
 * @FilePath: \vue-admin-koa2\koa2_api\module\schama\menu.js
 */

const mongoose = require('../db/mongodb');
const config = require('../config/config');
const menuSchema = mongoose.Schema({
  menu_id: { //一级菜单ID
    type: Number,
    require: true,
    trim: true
  },
  // submenu_id: { //关联一级菜单ID
  //   type: mongoose.Schema.Types.ObjectId,
  //   ref: 'Submenu'
  // },
  menu_name: { //一级菜单名称
    type: String,
    require: true,
    trim: true
  },
  menu_level: { //一级菜单权限
    type: Number,
    require: true,
    trim: true
  },
  menu_path: {  //菜单路径
    type: String,
    default: null
  },
  menu_icon: {  //菜单图标
    type: String,
    require: true,
    trim: true
  },
  menu_status: {  //菜单状态
    type: Number,
    default: 1
  },
  menu_createTime: { //菜单创建时间
    type: Date,
    default: Date.now
  },
  menu_updateTime: { //菜单更新时间
    type: Date,
    default: Date.now
  }
}, {
  timestamps: {
    createdAt: 'menu_createTime',
    updatedAt: 'menu_updateTime'
  }
})

module.exports = Menu = mongoose.model('Menu', menuSchema, `${config.mongodb.table}menu`);